home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
pascal
/
psgui130.zip
/
PGUIBUT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-01-01
|
14KB
|
477 lines
{
╔══════════════════╗
║ PGUI Graphic ║
║ Button Include ║
║ Rev. 1.00 ║
╚══════════════════╝
}
Procedure DrwButtonUp(X,Y,Len,Depth,Thickness,Background:Word;
Picture:Pointer;Name:String);
{ ╔════════════════════════════════════════════════════════════════════════╗ }
{ ║ Draw Button of Variable Size. ║ }
{ ║ ║ }
{ ║ Draw at X,Y with the specified Length, Depth, and Thickness. ║ }
{ ║ The current Background colour must be specified. ║ }
{ ╚════════════════════════════════════════════════════════════════════════╝ }
Var
Shape:Array[1..8] of Word;
Begin
Mouse.Hide;
SetFillStyle(SolidFill,LightGray);
Bar(X,Y,X+Len,Y+Depth-1);
SetColor(Background);
Line(X,Y+Depth,X+Len,Y+Depth);
SetColor(Black);
SetFillStyle(Solidfill,White);
Shape[1] := X;
Shape[2] := Y;
Shape[3] := X+Len;
Shape[4] := Y;
Shape[5] := X+Len-Thickness;
Shape[6] := Y+Thickness;
Shape[7] := X+Thickness;
Shape[8] := Y+Thickness;
FillPoly(4,Shape);
Shape[1] := X;
Shape[2] := Y;
Shape[3] := X;
Shape[4] := Y+Depth;
Shape[5] := X+Thickness;
Shape[6] := Y+Depth-Thickness;
Shape[7] := X+Thickness;
Shape[8] := Y+Thickness;
FillPoly(4,Shape);
SetFillStyle(solidfill,DarkGray);
Shape[1] := X;
Shape[2] := Y+Depth;
Shape[3] := X+Len;
Shape[4] := Y+Depth;
Shape[5] := X+Len-Thickness;
Shape[6] := Y+Depth-Thickness;
Shape[7] := X+Thickness;
Shape[8] := Y+Depth-Thickness;
FillPoly(4,Shape);
Shape[1] := X+Len;
Shape[2] := Y+Depth;
Shape[3] := X+Len;
Shape[4] := Y;
Shape[5] := X+Len-Thickness;
Shape[6] := Y+Thickness;
Shape[7] := X+Len-Thickness;
Shape[8] := Y+Depth-Thickness;
FillPoly(4,Shape);
OutTextXY(X+(Len-8*Length(Name)) DIV 2,(Y+(Depth-8) DIV 2)+Thickness-2,Name);
Mouse.Show;
End;
Procedure DrwButtonDown(X,Y,Len,Depth,Thickness:Word;Picture:Pointer;Name:String);
{ ╔════════════════════════════════════════════════════════════════════════╗ }
{ ║ Draw Button of Variable Size Being Pressed. ║ }
{ ╚════════════════════════════════════════════════════════════════════════╝ }
Begin
Mouse.Hide;
SetFillStyle(SolidFill,LightGray);
Bar(X,Y,X+Len,Y+Depth);
SetFillStyle(Solidfill,DarkGray);
Bar(X,Y,X+Len,Y+Thickness);
Bar(X,Y,X+Thickness,Y+Depth);
SetFillStyle(Solidfill,White);
Bar(X+Thickness,Y+Thickness,X+Len,Y+Thickness);
Bar(X+Thickness,Y+Thickness,X+Thickness,Y+Depth);
SetColor(Black);
Line(X,Y+Depth,X+Len,Y+Depth);
Line(X+Len,Y,X+Len,Y+Depth);
OutTextXY(X+(Len-8*Length(Name))DIV 2+Thickness,Y+(Depth-8) DIV 2+Thickness,Name);
Mouse.Show;
End;
Procedure DrawButtonUp(X1,Y1,X2,Y2,Thickness,Background:Word;Picture:Pointer;Name:String);
{ ╔════════════════════════════════════════════════════════════════════════╗ }
{ ║ Draw Button of Variable Size. ║ }
{ ╚════════════════════════════════════════════════════════════════════════╝ }
Begin
DrwButtonUp(X1,Y1,X2-X1+1,Y2-Y1+1,Thickness,Background,Picture,Name);
End;
Procedure DrawButtonDown(X1,Y1,X2,Y2,Thickness:Word;Picture:Pointer;Name:String);
{ ╔════════════════════════════════════════════════════════════════════════╗ }
{ ║ Draw Button of Variable Size Being Pressed. ║ }
{ ╚════════════════════════════════════════════════════════════════════════╝ }
Begin
DrwButtonDown(X1,Y1,X2-X1+1,Y2-Y1+1,Thickness,Picture,Name);
End;
Procedure ButtonChain.Init;
Begin
Root :=NIL;
Total :=0;
Buttons :=NIL;
End;
Function ButtonChain.Position:Word;
Var
B :Pointer;
X :Word;
Begin
X:=1;
B:=Buttons;
Buttons:=Root;
While (Buttons<>NIL) And (Buttons^.Next<>NIL) And (B<>Buttons) do
Begin
Inc(X);
Buttons:=Buttons^.Next;
End;
If (B<>Buttons) Or (B=NIL) Then Position:=0;
Buttons:=B;
End;
Function ButtonChain.Number:Word;
Begin
If Buttons=NIL Then
Number:=0
Else
Number:=Buttons^.Number;
End;
Procedure ButtonChain.GotoPosition(Here:Word);
Var
X :Word;
Begin
If Here=0 Then
Begin
Buttons:=NIL;
Exit;
End;
X:=1;
Buttons:=Root;
While (Buttons<>NIL) And (Buttons^.Next<>NIL) And (X<Here) do
Begin
Buttons:=Buttons^.Next;
Inc(X);
End;
End;
Procedure ButtonChain.GotoNumber(ButtonNumber:Word); {NIL if not found}
Begin
Buttons:=Root;
While (Buttons<>NIL) And (ButtonNumber<>Buttons^.Number) do
Buttons:=Buttons^.Next;
End;
Function ButtonChain.NewButtonNumber:Word;
Var
Highest:Word;
Begin
Buttons:=Root;
Highest:=0;
While Buttons<>NIL do
Begin
Highest:=Buttons^.Number;
Buttons:=Buttons^.Next;
End;
If Highest>65500 Then
Begin
Repeat
Highest:=Random(65499)+1;
Buttons:=Root;
While (Buttons<>NIL) And (Highest<>0) do
Begin
If Highest=Buttons^.Number Then Highest:=0;
Buttons:=Buttons^.Next;
End;
Until Highest<>0;
NewButtonNumber:=Highest;
End
Else
NewButtonNumber:=Highest+1;
End;
Procedure ButtonChain.Add(X1, Y1, X2, Y2:Word; Thickness,
Background:Word;
Picture:Pointer; Name:String;
Special:Boolean; Key:Char);
{ ╔════════════════════════════════════════════════════════════════════════╗ }
{ ║ ║ }
{ ║ The button is added to the list. Button coordinates are at X1,Y1 ║ }
{ ║ to X2,Y2. The equivalent key press is in Key. Special is True ║ }
{ ║ if the key returned if preceeded by a character 0. ║ }
{ ║ ║ }
{ ║ Background is the background colour, Picture is a possible ║ }
{ ║ Button picture and it returns a the button's number. ║ }
{ ║ ║ }
{ ╚════════════════════════════════════════════════════════════════════════╝ }
Var
P :ButtonListPtr; {New Button}
Begin
New(P);
P^.X1 :=X1;
P^.Y1 :=Y1;
P^.X2 :=X2;
P^.Y2 :=Y2;
P^.Thickness :=Thickness;
P^.Background :=Background;
P^.Picture :=Picture;
P^.Name :=Name;
P^.Number :=NewButtonNumber;
P^.Special :=Special;
P^.Key :=Key;
P^.Next :=NIL;
GotoPosition(65535);
If Root=NIL Then
Begin
Root:=P;
Buttons:=P;
End
Else
Begin
Buttons^.Next:=P;
Buttons:=P;
End;
Inc(Total);
End;
Procedure ButtonChain.Create(X1, Y1, X2, Y2:Word; Thickness,
Background:Word;
Picture:Pointer; Name:String;
Special:Boolean; Key:Char);
{ ╔════════════════════════════════════════════════════════════════════════╗ }
{ ║ Displays a Button, and adds it to a Linked List of Buttons. ║ }
{ ╚════════════════════════════════════════════════════════════════════════╝ }
Begin
Add(X1,Y1,X2,Y2,Thickness,Background,Picture,Name,Special,Key);
DrawButtonUp(X1,Y1,X2,Y2,Thickness,Background,Picture,Name);
End;
Procedure ButtonChain.WaitForClick(Var X, Y:Word;Var MouseButtons:Byte;
Var Held,Doubled,Special:Boolean; Var Key:Char);
{ ╔════════════════════════════════════════════════════════════════════════╗ }
{ ║ ║ }
{ ║ This procedure will return which of the currently active button